package com.coffee.mybatis;

import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;


public class MochaIdentifierGenerator implements IdentifierGenerator {

    //    private static final IdWorker ID_WORKER = new IdWorker(RandomKits.randomLong(~(-1 << 10)));
    //如果 workerId 不固定 那么 生成的ID 就不是有序的；  如果固定 那么 就是有序的；
    // wokerId 值越小 那么生成的ID 也越小
    private static final IdWorker ID_WORKER = new IdWorker(123L);

    @Override
    public boolean assignId(Object idValue) {
        return IdentifierGenerator.super.assignId(idValue);
    }

    @Override
    public Number nextId(Object entity) {
        return ID_WORKER.nextId();
    }

    @Override
    public String nextUUID(Object entity) {
        return IdentifierGenerator.super.nextUUID(entity);
    }
}
